package com.ayoka.parenting.adapter;

import com.ayoka.parenting.R;
import com.ayoka.parenting.bean.MeditationBean;
import com.jincp.common.brvah.BaseQuickAdapter;
import com.jincp.common.brvah.BaseViewHolder;


/**
 * @ProjectName: ayoka7.
 * @ClassName: CourseClassroomMemberAdapter.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/8/6 21:15.
 */

public class MeditationAudioAdapter extends BaseQuickAdapter<MeditationBean.MeditationVoiceBean, BaseViewHolder> {


    public MeditationAudioAdapter() {
        super(R.layout.item_meditation_audio);
    }

    @Override
    protected void convert(BaseViewHolder holder, MeditationBean.MeditationVoiceBean item) {
        holder.setText(R.id.tv_audio_title, item.Name)
                .setSelected(R.id.tv_audio_title, item.isSelected);
    }

    private int previousSelectedIndex;

    public void setSingleChoice(int position) {
        getData().get(position).isSelected = true;
        notifyItemChanged(position);
        if (position != previousSelectedIndex) {
            getData().get(previousSelectedIndex).isSelected = false;
            notifyItemChanged(previousSelectedIndex);
        }
        previousSelectedIndex = position;
    }
}
